<div class="_contro">
	<a href="/home/goods/" class="_a"><font class="_font">返回</font></a>
</div>
<div class='_cut'></div>
    <div class="preview_div">
    	     <div class='box'>              
                <img src="<?php echo "http://".IMAGE_DOMAIN.$item['images'][0]['image']; ?>" style='width:200px;height:200px;float:left;' >
                <?php if($item['images'][1]['image']){ ?>
                <img src="<?php echo "http://".IMAGE_DOMAIN.$item['images'][1]['image']; ?>" style='width:200px;height:200px;float:right;' >
                <?php } ?>
                <br/>
            </div>
            <div class='_cut2' style='clear:both;' ></div> 
      		<div class='box'>
      			<?php $type = $item['type']; if($type==0){ $mark='lf.png';}elseif($type==1){ $mark='tr.png';}elseif($type==2){ $mark='hl.png';}elseif($type==3){ $mark='yq.png';}elseif($type==4){ $mark='rg.png';}?>
                        <img class='_img' src="/public/images/<?php echo $mark; ?>" style='width:25%;'/>&nbsp;                
               <span style='font-size:2.5rem' ><?php echo $item['name'] ;?></span> 
            </div>
            <div class='box' style='margin-left:11rem;' >
            	<span class='colors-size'>——<?php echo $item['title'];?></span>
            </div> 
      		<div class='box'>
      			包含:<br>
      			<?php if($item['is_meal_set']==0){ ?>
    			<span style='font-size:1.7rem;margin-left:2.5rem;' ><?php echo $item['name'];?></span>
    			<?php }else{ ?>
    			<?php foreach ($item['items'] as $k => $v) { ?>
    			<span style='font-size:1.7rem;margin-left:2.5rem;' ><?php echo $v['name'];?>—<span style='color:red' ><?php echo $v['number'];?></span>次</span> <br/>
    			<?php } ?>
    			<?php } ?>
            </div> 
            <div class='box'  >价格：￥<span style='color:red;font-size:2rem;' ><?php echo ($item['price']/100); ?></span></div>
            
			<?php $level = json_decode($item['level'],true); if($level==0){  ?>
			<div class='box' style='margin-top:1rem' >适用范围:<span style='font-size:1.7rem;' >所有</span> </div>
			<?php }else{  ?>
				<div class='box' style='margin-top:1rem' >适用范围:
				<?php foreach($level as $v){   ?>
				<?php if($v==1){ $v= '高级发型师';}elseif($v==2){ $v= '高级总监';}elseif($v==3){ $v= '高级顾问';}elseif($v==4){ $v= '高级美容师';}elseif($v==5){ $v=  '高级经理';}elseif($v==6){ $v='高级助理';} ?>
				<span style='font-size:1.7rem;'><?php echo $v ?> / </span> 
				<?php   } } ?>
				<div class='box'  ><?php echo $item['intro'] ?> </div>
				<div class='_line' ></div>
				<div class='_cut2' ></div>
				<div id='content_evaluate' >
					<?php if($evaluates){  ?>
						<?php foreach($evaluates as $k=>$v){ ?>
							<div>
		                         用户：<?php echo $v['user']['mobile']; ?>
		                    </div>
		                    <div style='padding:1rem 0 0 5%;' >
		                        评价：<?php  if( $v['relpy'] != '' ){ echo $v['relpy']; }else{ echo $v['content']; }  ?>
		                    </div>
		                    <?php if($v['evaluate_id']!=0){ ?>
		                    <div style='padding:1rem 0 0 8%;'>
		                        <span style='color:#FF8C00;' >商家回复</span>：<?php echo $v['content']; ?>
		                    </div>
		                    <?php }else{  ?>
		                    <div style='float:right;font-size:1.5rem;color:red;'  >
		                    	<span  onclick="relpy(this)" >回复</span>			 
		                    </div>
		                    <div style='display: none' >
			                    	<div style='color:black;'>
			                    		<textarea name='_text' id='_text'  class='_textarea'  ></textarea>
			                    	</div>
			                    	<div  style='text-align:center;' >
			                    		<input type='hidden' id='client_id' value='<?php echo $v['client_id'];?>' >
			                    		<input type='hidden' id='order_number' value='<?php echo $v['order_number'];?>' >
			                    		<input type='hidden' id='' value='<?php echo $v['id'];?>' >
			                    		<input  style='width:30%;' name='' type='button' onclick="_submit(this)"  value='提交回复' >
			                    		<input  style='width:30%;' name='' type='button'  onclick="cancel(this)"  value='取消' >
			                    	 </div>
			                    </div>
		                    <?php } ?>
		                    <div class='_line'></div>
		                    <hr>
						<?php } ?>	
					<?php }else{ ?>
						<span>该商品暂无评价！！</span>
					<?php } ?>
				</div>
				<input type='hidden' id='store_id' value='<?php echo $item['store_id'];?>' >
				<input type='hidden' id='item_id' value='<?php echo $item['id'];?>' >
				<input type='hidden' id='item_number' value='<?php echo $item['item_number'];?>' >
			</div>
<script type="text/javascript">
    $(document).ready(function(){

    var number =12;
    function loaddata()
    {
        var item_number = $("#item_number").val();
        var store_id = $("#store_id").val();
        var item_id = $("#item_id").val();
        if (number == -1) {
            return;
        }
        totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());

        if ($(document).height() <= totalheight)
        {
            $.ajax({url: "/home/evaluate/append?store_id="+store_id+"&start=" + number+"&item_number=" + item_number, async: true, 
                success: function (msg) {
                    if (msg == '') {
                        number = -1;
                        return;
                    }

                    var html = "";
                    msg = eval('(' + msg + ')');
                        $.each(msg, function (i,v){


							html += "<div>用户："+v.user.mobile+"</div>";
							html += "<div style='padding:1rem 0 0 5%;' >评价：";
							if(v.relpy != undefined ){ 
								html += v.relpy;
							}else{ 

								html += v.content;
							}
							html += "</div>";
							if(v.evaluate_id!=0){
								html += "<div style='padding:1rem 0 0 8%;'><span style='color:#FF8C00;' >商家回复</span>："+v.content+"</div>";
							}else{
								html += "<div style='float:right;font-size:1.5rem;color:red;'  ><span  onclick='relpy(this)' >回复</span></div>";
								html += "<div style='display: none' ><div style='color:black;'><textarea name='_text' id='_text'  class='_textarea'  ></textarea></div>";
								html += "<div  style='text-align:center;' ><input type='hidden' id='client_id' value='"+v.client_id+"' >";
				                html += "<input type='hidden' id='order_number' value='"+v.order_number+"' >";
				                html += "<input type='hidden' id='' value='"+v.id+"' >";
				                html += "<input  style='width:30%;' name='' type='button' onclick='_submit(this)'  value='提交回复' >";
				                html += "<input  style='width:30%;' name='' type='button'  onclick='cancel(this)'  value='取消' ></div></div>";

							}
								html += "<div class='_line'></div><hr>";
	                            number += 1;
                        });
                    $('#content_evaluate').append(html);
                }});
        }
    }

    $(window).scroll(function () {
        loaddata();
    });
   })
	function relpy(obj){
    	$(obj).parent().next().toggle(1000);
          
    } 
    function cancel(th){
    	$(th).parent().prev().children().val('');
    	$(th).parent().parent().toggle(1000);
    }
    function _submit(thi){
    	var content = $(thi).parent().prev().children().val();
    	var evaluate_id = $(thi).prev().val();
    	var order_number= $(thi).prev().prev().val();
    	var client_id= $(thi).prev().prev().prev().val();
    	var item_number = $("#item_number").val();
    	var item_id = $("#item_id").val();
        var store_id = $("#store_id").val();
        if(content.length<5){
            alert('请回复不少于5个字！');
            return;
        }
        $.ajax({url: "/home/evaluate/reply_submit?store_id="+store_id, async: true,
        		type: 'POST',
        		data:{'content':content,'order_number':order_number,'evaluate_id':evaluate_id,'item_number':item_number,'item_id':item_id,'client_id':client_id}, 
                success: function (msg) {
                    if (msg == 'false') {
                        alert('回复失败！');
                        return;
                    }else{
                    	alert('回复成功！');
                    	window.location.reload();
                    }

        }});
        
    }

</script>
